package cn.edu.zafu.bigdata.smj.a;

class InvalidAgeException extends Exception{
    public InvalidAgeException(String msg) {
        super(msg);
    }
}
public class ageCheck {
    public static void checkAge(int age) throws InvalidAgeException {
        if (age < 18) {
            throw new InvalidAgeException("年龄小于18岁，不符合要求。");
        }
        System.out.println("年龄符合要求。");
    }
    public static void main(String[] args) {
        try {
            checkAge(16);
        } catch (InvalidAgeException e) {
            System.out.println("错误: " + e.getMessage());
        }
    }
}
